import request from '@/utils/request'

const prefix = "/api/question"

/** 
 * 获取科目题目
 * @returns
 */
function questionList(subjectId) {
	return request({
		url: prefix + '/questionList/' + subjectId,
		method: 'get'
	})
}

/** 
 * 获取题目详情
 * @returns
 */
function Question(id) {
	return request({
		url: prefix + '/question/' + id,
	})
}

/**
 * 全部题目（顺序）
 */
function sequenceQuestionList(params) {
	return request({
		url: prefix + '/sequenceQuestionList',
		method: 'get',
		params
	})
}

/**
 * 乱序刷题
 */
function shuffledQuestionList() {
	return request({
		url: prefix + '/shuffledQuestionList',
	})
}


/**
 * 易错题集
 */
function error99QuestionList() {
	return request({
		url: prefix + '/error99QuestionList',
	})
}

/**
 * 用户的错题集（章节ID）
 */
function errorCollectSetQuestionList(chapterId,type) {
	return request({
		url: prefix + '/errorCollectSetQuestionList/' + chapterId + '/' + type,
	})
}



/**
 * 添加到错题/收藏集
 * @returns
 */
function addToErrorOrCollectSet(data) {
	return request({
		url: prefix + '/addToErrorOrCollectSet',
		method: 'post',
		data
	})
}


/**
 * 获取题目选项
 * @param {*} questionId 
 * @returns
 */
function questionOptionsList(questionId) {
	return request({
		url: prefix + '/questionOptions/' + questionId,
		method: 'get'
	})
}

/**
 * 获取是否用户已收藏
 * @param {*} questionId 
 * @returns
 */
function IsCollect(questionId) {
	return request({
		url: prefix + '/isCollect/' + questionId,
		method: 'get'
	})
}

/**
 * 取消收藏
 * @param {*} questionId 
 * @returns
 */
function UnCollect(questionId) {
	return request({
		url: prefix + '/unCollect/' + questionId,
		method: 'delete'
	})
}


/**
 * 添加刷题记录
 * @returns
 */
function addQuestionRecord(data) {
	return request({
		url: prefix + '/addQuestionRecord',
		method: 'post',
		data
	})
}




export default {
	Question,
	IsCollect,
	UnCollect,
	questionList,
	sequenceQuestionList,
	shuffledQuestionList,
	questionOptionsList,
	error99QuestionList,
	addToErrorOrCollectSet,
	errorCollectSetQuestionList,
	addQuestionRecord
}